package com.dsh.userSetting.controller;

import com.dsh.model.Result;
import com.dsh.userSetting.entity.vo.*;
import com.dsh.userSetting.service.AgreementService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@Api(tags = "协议管理")
@RestController
@RequestMapping("UserAgreement")
public class UserAgreementController {
    @Resource
    AgreementService agreementService;

    @ApiOperation(value = "更新注册协议", response = UserAgreementVo.class)
    @PostMapping("selectUserAgreement")
    public Result selectUserAgreement(UserAgreementVo userAgreementVo) {
        UserAgreementVo userAgreementVo1 = agreementService.selectUserAgreement(userAgreementVo);
        return Result.success(userAgreementVo1, "");
    }

    @ApiOperation(value = "更新隐私协议", response = UserPrivacyVo.class)
    @PostMapping("selectUserPrivacy")
    public Result selectUserPrivacy(UserPrivacyVo userPrivacyVo) {
        UserPrivacyVo userPrivacyVo1 = agreementService.selectUserPrivacy(userPrivacyVo);
        return Result.success(userPrivacyVo1, "");
    }

    @ApiOperation(value = "更新充值协议", response = UserRechargeVo.class)
    @PostMapping("selectUserRecharge")
    public Result selectUserRecharge(UserRechargeVo userRechargeVo) {
        UserRechargeVo userRechargeVo1 = agreementService.selectUserRecharge(userRechargeVo);
        return Result.success(userRechargeVo1, "");
    }

    @ApiOperation(value = "级别权益说明", response = UserLevelVo.class)
    @PostMapping("selectUserLevel")
    public Result selectUserLevel(UserLevelVo userLevelVo) {
        UserLevelVo userLevelVo1 = agreementService.selectUserLevel(userLevelVo);
        return Result.success(userLevelVo1, "");
    }

    @ApiOperation(value = "会员升级", response = UserUpgradeVo.class)
    @PostMapping("selectUserUpgrade")
    public Result selectUserUpgrade(@RequestBody UserUpgradeVo userUpgradeVo) {
        UserUpgradeVo userUpgradeVo1 = agreementService.selectUserUpgrade(userUpgradeVo);
        return Result.success(userUpgradeVo1, "");
    }

    @ApiOperation(value = "查看全部的会员升级规则", response = ConditionsVo.class)
    @GetMapping("selectAll")
    public Result selectAll() {
        List<ConditionsVo> conditionsVos = agreementService.selectAll();
        return Result.success(conditionsVos, "");
    }

    @ApiOperation(value = "增添会员升级规则", response = ConditionsVo.class)
    @PostMapping("insertRule")
    public Result insertRule(@RequestBody ConditionsVo conditionsVo) {
        int i = agreementService.insertRule(conditionsVo);
        return Result.success(i, "");
    }

    @ApiOperation(value = "根据id查询会员升级规则", response = ConditionsVo.class)
    @GetMapping("selectAllById")
    public Result selectAllById(int id) {
        ConditionsVo conditionsVo = agreementService.selectAllById(id);
        return Result.success(conditionsVo, "");
    }

    @ApiOperation(value = "修改会员升级规则", response = ConditionsVo.class)
    @PostMapping("updateRule")
    public Result updateRule(@RequestBody ConditionsVo conditionsVo) {
        int i = agreementService.updateRule(conditionsVo);
        return Result.success(i, "");
    }

    @ApiOperation(value = "充值策略", response = StrategyVo.class)
    @GetMapping("selectAllStrategy")
    public Result selectAllStrategy() {
        List<StrategyVo> strategyVos = agreementService.selectAllStrategy();
        return Result.success(strategyVos, "");
    }

    @ApiOperation(value = "根据策略id查询充值赠送集合", response = RechargeAndGiftVo.class)
    @GetMapping("selectRechargeAndGiftBySId")
    public Result selectRechargeAndGiftBySId(int sId) {
        List<RechargeAndGiftVo> rechargeAndGiftVos = agreementService.selectRechargeAndGiftBySId(sId);
        return Result.success(rechargeAndGiftVos, "");
    }

    @ApiOperation(value = "修改充值赠送", response = RechargeAndGiftVo.class)
    @PostMapping("updateRechargeAndGift")
    public Result updateRechargeAndGift(@RequestBody ListRechargeAndGiftVo ListRechargeAndGiftVo) {
        this.agreementService.updateRechargeAndGift(ListRechargeAndGiftVo.getRechargeAndGiftVos());
        return Result.success("");
    }
    @ApiOperation("根据adminId查询所在片区")
    @ApiImplicitParam(paramType = "query", name = "uId", value = "adminId", required = true, dataType = "int")
    @GetMapping("selectAreaByAdminId")
    public Result selectAreaByAdminId(int uId) {
        List<AreaByAdminVo> areaByAdminVos = agreementService.selectAreaByAdminId(uId);
        return Result.success(areaByAdminVos, "");
    }
    @ApiOperation("根据片区Id查询所在机构")
    @ApiImplicitParam(paramType = "query", name = "aId", value = "片区id", required = true, dataType = "int")
    @GetMapping("selectStoreByAreaId")
    public Result selectStoreByAreaId(int aId){
        List<StoreAndAreaVo> storeAndAreaVos = agreementService.selectStoreByAreaId(aId);
        return Result.success(storeAndAreaVos,"");
    }
    @ApiOperation(value = "修改门店的策略",response = StoreAndAreaVo.class)
    @PostMapping("updateStrategyToStore")
    public Result updateStrategyToStore(@RequestBody ListStoreAndAreaVo listStoreAndAreaVo){
        this.agreementService.updateStrategyToStore(listStoreAndAreaVo.getList());
        return Result.success("");
    }
}

